<!DOCTYPE html>
<html>
    <head>
        <script src="echarts.min.js"></script>
        <script src="jquery.min.js"></script>
    </head>
    <body>

        <input type="button" name="name" value="导出" id="export"  style="width: 100px;height: 20px;background-color: red;" >导出</input>


           
        <form id="chartForm" style="display:none" method="post" enctype="multipart/form-data" action="https://localhost:8080/export">
            <input id="imageValue" name="base64Info" type="text" maxlength="50000" />
            <input id="imageValue" name="fileType" type="text" value=".png" />
        </form>
        <!-- prepare a DOM container with width and height -->
    <div id="main" style="width: 600px;height:400px;">
     
    </div>
    <script type="text/javascript">
        // based on prepared DOM, initialize echarts instance
        var myChart = echarts.init(document.getElementById('main'));

        // specify chart configuration item and data
        var option = {
            title: {
                text: 'ECharts entry example'
            },
            tooltip: {},
            legend: {
                data:['Sales']
            },
            xAxis: {
                data: ["shirt","cardign","chiffon shirt","pants","heels","socks"]
            },
            yAxis: {},
            series: [{
                name: 'Sales',
                type: 'bar',
                data: [5, 20, 36, 10, 10, 20]
            }]
        };

        // use configuration item and data specified to show chart
        myChart.setOption(option);
        //导出
 $('#export').on('click', function () {
    alert('111');
    var chartExportUrl = 'https://localhost:8080/export';
    var picBase64Info = myChart.getDataURL();//获取echarts图的base64编码，为png格式。

    $('#chartForm').find('input[name="base64Info"]').val(picBase64Info);//将编码赋值给输入框                                               
    $('#chartForm').submit();
});
    </script>
    </body>
</html>
